package com.school.serviceImpl;

import com.school.dao.RoleMapper;
import com.school.model.Role;
import com.school.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


@Service
public class RoleServiceImpl implements RoleService {
    @Autowired(required = false)
    private RoleMapper roleMapper;


    @Override
    public synchronized int insertSelective(Role record) {
        if(roleMapper.selectByName(record.getName())!=null){
            return  -1;
        }
        record.setCreateTime(new Date());
        record.setIsDelete(1);
        return roleMapper.insertSelective(record);
    }

    @Override
    public int updateByPrimaryKeySelective(Role record) {
        if(roleMapper.selectByName(record.getName())!=null){
            return  -1;
        }
        record.setModifyTime(new Date());
        return roleMapper.updateByPrimaryKeySelective(record);
    }

}
